Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial version of crate #1

Merged
merged 13 commits into from
Mar 26, 2024
Merged

Initial version of crate #1

merged 13 commits into from
Mar 26, 2024

Conversation

leftmostcat
Copy link
Collaborator

It's my hope that the documentation in the crate is sufficient that most things here will be self-explanatory. Please do ask questions if it isn't, because then I can make my docs better.

@@ -0,0 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These build tests are currently incomplete. Missing tests include fields of types which don't implement the appropriate traits, fields of types which don't implement the appropriate traits but do have identically-named methods, and probably a battery of tests to validate that all of our happy-path cases compile properly (although this is kind of handled by the integration tests as well).

Copy link
Member

@babolivier babolivier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't fully reviewed the patch yet (I've reviewed most of the property processing and some of the code generation), but wanted to submit this to smooth out the work a bit (rather than landing one huge review weeks later).

Overall my main issue is that I find the code quite lacking in terms of comments. imo comments should not only be used to explain potentially tricky bits of the code, but also to provide a human-readable explanation of what a given portion does to guide someone through their first look reading the code, since parsing code requires much more effort than reading a comment that summarises what it does. This is especially true from an accessibility point of view: contributors using screen readers will have the code read one line at a time, and might not be able to grasp the context of a given line as easily as sighted folks; having an explanation of what the code does beforehand helps provide this context.

xml_struct/src/lib.rs Show resolved Hide resolved
xml_struct_derive/src/lib.rs Outdated Show resolved Hide resolved
xml_struct_derive/src/lib.rs Show resolved Hide resolved
xml_struct/src/impls.rs Outdated Show resolved Hide resolved
xml_struct_derive/src/properties.rs Outdated Show resolved Hide resolved
xml_struct_derive/src/properties.rs Outdated Show resolved Hide resolved
xml_struct_derive/src/lib.rs Show resolved Hide resolved
xml_struct_derive/src/lib.rs Show resolved Hide resolved
xml_struct_derive/src/properties.rs Show resolved Hide resolved
@leftmostcat
Copy link
Collaborator Author

I haven't fully reviewed the patch yet (I've reviewed most of the property processing and some of the code generation), but wanted to submit this to smooth out the work a bit (rather than landing one huge review weeks later).

Overall my main issue is that I find the code quite lacking in terms of comments. imo comments should not only be used to explain potentially tricky bits of the code, but also to provide a human-readable explanation of what a given portion does to guide someone through their first look reading the code, since parsing code requires much more effort than reading a comment that summarises what it does. This is especially true from an accessibility point of view: contributors using screen readers will have the code read one line at a time, and might not be able to grasp the context of a given line as easily as sighted folks; having an explanation of what the code does beforehand helps provide this context.

I'd love to add additional comments; the biggest difficulty here is, of course, that I wrote the code and know what it does. I'd greatly appreciate it if you could leave a quick note anywhere where you feel that understanding what's happening is non-trivial.

@leftmostcat leftmostcat requested a review from babolivier March 4, 2024 18:27
Copy link
Member

@babolivier babolivier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The crate looks good to me from a functional point of view (I have used it without any issue and haven't seen noticed significant functional issue during my review), so most of my comments relate to documentation and readability. I haven't gotten around to looking at the tests crate yet, I'll look at it in a future round.

xml_struct_derive/src/lib.rs Show resolved Hide resolved
xml_struct_derive/src/properties.rs Show resolved Hide resolved
xml_struct/src/lib.rs Show resolved Hide resolved
xml_struct/src/impls.rs Outdated Show resolved Hide resolved
xml_struct/src/impls.rs Show resolved Hide resolved
xml_struct_derive/src/serialize/codegen.rs Outdated Show resolved Hide resolved
xml_struct_derive/src/serialize/codegen.rs Outdated Show resolved Hide resolved
xml_struct_derive/src/serialize/codegen.rs Outdated Show resolved Hide resolved
xml_struct_derive/src/serialize/codegen.rs Show resolved Hide resolved
xml_struct_derive/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@babolivier babolivier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Just found an issue with one example, and left a few non-blocking suggestions. The code looks much more approachable and readable now with the structure and comment changes you've made, thanks for bearing with me on this!

@@ -12,6 +12,7 @@ use quick_xml::{

use crate::{Error, XmlSerialize, XmlSerializeAttr};

/// Serializes a string as a text content node.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (non-blocking): I think it could be helpful to mention how it interacts with the Writer it borrows from the consumer, i.e what event(s) each impl send (or doesn't). Same for the otherimpl blocks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raises an interesting question of where the line is between implementation details and visible side effects. Given how easy autogenerated Rust docs make it to access the source, I'm going to lean toward "describe in comments, let them check source if they really need details".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where the line is between implementation details and visible side effects

fwiw I think that if the writer is given to us by the consumer, then it means the consumer might want to write more stuff into it, in which case what's already in there should be easy to infer from the documentation.

xml_struct/src/lib.rs Outdated Show resolved Hide resolved
xml_struct_derive/src/lib.rs Outdated Show resolved Hide resolved
xml_struct_derive/src/lib.rs Outdated Show resolved Hide resolved
xml_struct_derive/src/properties.rs Outdated Show resolved Hide resolved
xml_struct_derive/src/serialize/codegen.rs Show resolved Hide resolved
xml_struct_derive/src/serialize/codegen.rs Outdated Show resolved Hide resolved
xml_struct_tests/src/lib.rs Show resolved Hide resolved
xml_struct/src/lib.rs Show resolved Hide resolved
Copy link
Contributor

@ikeycode ikeycode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually going to approve this at this stage, because a) its good work and b) i far prefer incremental development.

Please do consider the simplification and robustness points around errors though, for more information see: https://gist.github.com/quad/a8a7cc87d1401004c6a8973947f20365

@leftmostcat leftmostcat merged commit ace285b into main Mar 26, 2024
@leftmostcat leftmostcat deleted the initial-import branch October 28, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants